package com.webchat.pgc.controller.mall;

import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.domain.vo.request.mall.SaveMallCategoryRequestVO;
import com.webchat.domain.vo.response.mall.MallCategoryResponseVO;
import com.webchat.pgc.service.mall.MallCategoryService;
import com.webchat.rmi.pgc.mall.MallCategoryClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class MallCategoryController implements MallCategoryClient {


    @Autowired
    private MallCategoryService mallCategoryService;

    @Override
    public APIResponseBean<Long> save(SaveMallCategoryRequestVO requestVO) {

        return APIResponseBeanUtil.success(mallCategoryService.saveCategory(requestVO));
    }

    @Override
    public APIResponseBean<Boolean> publish(Long id, String userId) {

        return APIResponseBeanUtil.success(mallCategoryService.publish(id, userId));
    }

    @Override
    public APIResponseBean<Boolean> invoke(Long id, String userId) {

        return APIResponseBeanUtil.success(mallCategoryService.invoke(id, userId));
    }

    @Override
    public APIResponseBean<Boolean> delete(Long id, String userId) {

        return APIResponseBeanUtil.success(mallCategoryService.delete(id, userId));
    }

    @Override
    public APIResponseBean<Boolean> updateRank(Long id, Integer rank, String userId) {

        return APIResponseBeanUtil.success(mallCategoryService.updateRank(id, rank, userId));
    }

    @Override
    public APIResponseBean<List<MallCategoryResponseVO>> list() {

        return APIResponseBeanUtil.success(mallCategoryService.listAll());
    }
}
